package com.design.model.visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: study
 * @className: ObjectStructure
 * @description: TODO
 * @author: kukuxiahuni
 * @create: 2019-06-24 20:34
 * @version: v1.0
 **/
public class ObjectStructure {

    private List<Person> elements = new ArrayList<>();

    /**
     * 功能描述: TODO
     * @param:
     * @return:
     * @auther: kukuxiahuni
     * @date: 2019/6/24 8:34 PM
     * @modify_auther: kukuxiahuni
     * @modify_time: 2019/6/24 8:34 PM
     **/
    public void add(Person element) {
        this.elements.add(element);
    }

    /**
     * 功能描述: TODO
     * @param:
     * @return:
     * @auther: kukuxiahuni
     * @date: 2019/6/24 8:35 PM
     * @modify_auther: kukuxiahuni
     * @modify_time: 2019/6/24 8:35 PM
     **/
    public void remove(Person element) {
        this.elements.remove(element);
    }

    /**
     * 功能描述: 展示
     * @param:
     * @return:
     * @auther: kukuxiahuni
     * @date: 2019/6/24 8:35 PM
     * @modify_auther: kukuxiahuni
     * @modify_time: 2019/6/24 8:35 PM
     **/
    public void display(Action visitor) {
        elements.forEach(
                e -> e.accept(visitor)
        );
    }


    public static void main(String[] args) {
        ObjectStructure objectStructure = new ObjectStructure();
        objectStructure.add(new Man());
        objectStructure.add(new Woman());

        Success success = new Success();

        objectStructure.display(success);
    }
}
